home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Developer Utilities / Installer 4.0.3 SDK / Script Examples / PowerMac vs 68K Rules Example / powerMac.r < prev    next >
Encoding:
Text File  |  1994-09-12  |  12.8 KB  |  428 lines  |  [TEXT/MPS ]

  1. //
  2. //    powerMac.r
  3. //
  4. //        This example demonstrates usage of the Easy and Custom Install frameworks 
  5. //        to create a customized installation depending on whether the target machine 
  6. //        is a Power Macintosh or a 68000 CPU machine.
  7. //
  8. //        All files are installed to folder "PowerMac Rules Example:" on root folder 
  9. //        of selected target volume for the installation.
  10. //
  11. //        NOTE: This example uses Gestalt calls to determine the CPU of the target 
  12. //        machine of the installation. Some machines with STP cards in them are 
  13. //        actually both PowerMac and 68K, but via a Control Panel the user can select 
  14. //        which machine they want their Mac to behave as. This example script will 
  15. //        install the appropriate modules during Easy Install for whichever CPU the 
  16. //        target machine is currently set up as. Because of the STP upgrade card 
  17. //        situation, most scriptwriters will actually want to include all possible 
  18. //        installation scenarios under Custom Install. 
  19. //
  20. //         IMPORTANT: It should be noted that this example portrays TeachText as being 
  21. //        specialized to work on either a Power Macintosh or 68000 machine. There is 
  22. //        no factual basis for this portrayal.  TeachText is used only as an example 
  23. //        and has not mutated while we were not looking.
  24. //
  25. //
  26. //        mark young • 08/18/94
  27. //
  28. //        Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
  29. //
  30.  
  31.  
  32. #include "InstallerTypes.r"
  33.  
  34.  
  35. // constants for Gestalt call to determine whether PowerMac or 68K CPU
  36. #define gestaltSystemType            'sysa'  // tells Gestalt to check CPU
  37. #define gestalt68Ksysa                1        // tells Gestalt to look for 68K CPU's
  38. #define gestaltPPCsysa                2        // tells Gestalt to look for PowerMac CPU's
  39.  
  40. // constants for packages, comments, comment text
  41. #define     kPowerMacPackage    100
  42. #define     k68000Package        200
  43. #define     kSeperatorLine        9999
  44.  
  45.  
  46. // • easy install setup
  47.  
  48. // easy install framework uses ID other than 765 or 766
  49. // recommended to always use ID 764
  50. resource 'infr' (764) {
  51.     format0 {{
  52.         // execute first true rule, if none are true then return false
  53.         pickFirst, { 700, 800, 900 },    // check CPU version, if illegal for
  54.                                         // this installation then give an error
  55.     }}
  56. };
  57.  
  58. // rule that adds Power Macintosh version file to Easy Install
  59. resource 'inrl' (700) {
  60.     format0 {{
  61.         // this returns false unless CPU is Power Macintosh
  62.         CheckGestalt{ gestaltSystemType, { gestaltPPCsysa }},
  63.         
  64.         // if Power Macintosh CPU add that package
  65.         AddPackages{{ kPowerMacPackage }},
  66.         AddUserDescription{ "Install the PowerMac version TeachText to \"PowerMac Rules Example\" folder." },
  67.     }}
  68. };
  69.  
  70. // rule that adds 68K version file to Easy Install
  71. resource 'inrl' (800) {
  72.     format0 {{
  73.         // this returns false unless CPU is 68K
  74.         CheckGestalt{ gestaltSystemType, { gestalt68Ksysa }},
  75.         
  76.         // if 68000 CPU add that package
  77.         AddPackages{{ k68000Package }},
  78.         AddUserDescription{ "Install the 68K version of TeachText to \"PowerMac Rules Example\" folder." },
  79.     }}
  80. };
  81.  
  82.  
  83. // • custom install setup
  84.  
  85. // custom install framework always uses ID of 766
  86. resource 'infr' (766) {
  87.     format0 {{
  88.         pickFirst, { 1000, 1100, 900 },    // if not a supported CPU, give error
  89.     }}
  90. };
  91.  
  92. // rule that checks CPU version of target machine
  93. resource 'inrl' (1000) {
  94.     format0 {{
  95.         // this returns false unless CPU is PowerMacintosh
  96.         CheckGestalt{ gestaltSystemType, { gestaltPPCsysa }},
  97.         
  98.         // add both PowerMac and 68K packages to Custom Install selections
  99.         AddCustomItems{{ kPowerMacPackage, kSeperatorLine, k68000Package }},
  100.     }}
  101. };
  102.  
  103. // rule that checks CPU version of target machine
  104. resource 'inrl' (1100) {
  105.     format0 {{
  106.         // this returns false unless CPU is 68K
  107.         CheckGestalt{ gestaltSystemType, { gestalt68Ksysa }},
  108.  
  109.         // add just the 68K package to Custom Install selections
  110.         AddCustomItems{{ k68000Package }},
  111.     }}
  112. };
  113.  
  114. // • used in both easy and custom
  115. resource 'inrl' (900) {
  116.     format0 {{
  117.         // ReportSysError disables both the INSTALL and SWITCH DISK buttons
  118.         ReportSysError{ "Power Macintosh or 68000 family CPU required for installation !!" }
  119.     }}
  120. };
  121.  
  122.  
  123. // • packages
  124.  
  125. // Power Macintosh
  126. resource 'inpk' ( kPowerMacPackage ) {
  127.     format0 {
  128.         showsOnCustom,            // if a subpackage, show in Custom Install
  129.         removable,                // include as a removeable item
  130.         dontForceRestart,        // don't make user reboot after installation
  131.         kPowerMacPackage,        // ID of package comments ( 'inpc' ), defined below
  132.         0,                        // Package size ( if 0, filled in by ScriptCheck )
  133.         
  134.         "PowerMac - TeachText to \"PowerMac Rules Example\" folder.",        
  135.                                 // Custom Install selection text
  136.                                 
  137.                                 
  138.         {        // Package parts list ( all the stuff to be include in package )
  139.                 // These parts can be 'inpk', 'infa', 'inra', 'inr#', 'inrm',
  140.                 // 'inff', 'infm', 'inaa', 'inat', 'inat', or 'inbb'
  141.                                                                 
  142.         'infa', 1075;            // 7.5 compatable file
  143.         },
  144.     }
  145. };
  146.  
  147.  
  148. // seperator line in Custom Install list of options
  149. resource 'inpk' ( kSeperatorLine ) {
  150.     format0 {
  151.         showsOnCustom,            // if a subpackage, show in Custom Install
  152.         
  153.         notRemovable,            // don't allow selection of seperator line 
  154.                                 // for removal
  155.                                 
  156.         dontForceRestart,        // don't make user reboot after installation
  157.         0,                        // no comments for a seperator line
  158.         0,                        // no size for a seperator line
  159.         "-",                    // display a dashed line in Custom Install 
  160.         {    
  161.                                 // parts list is empty for seperator line
  162.         },
  163.     }
  164. };
  165.  
  166. // 7.5 or greater
  167. resource 'inpk' ( k68000Package ) {
  168.     format0 {
  169.         showsOnCustom,            // if a subpackage, show in Custom Install
  170.         removable,                // include as a removeable item
  171.         dontForceRestart,        // don't make user reboot after installation
  172.         k68000Package,            // ID of package comments ( 'inpc' ), defined below
  173.         0,                        // Package size ( if 0, filled in by ScriptCheck )
  174.         
  175.         "68K - TeachText to \"PowerMac Rules Example\" folder.",        
  176.                                 // Custom Install selection text
  177.                                 
  178.                                 
  179.         {        // Package parts list ( all the stuff to be include in package )
  180.                 // These parts can be 'inpk', 'infa', 'inra', 'inr#', 'inrm',
  181.                 // 'inff', 'infm', 'inaa', 'inat', 'inat', or 'inbb'
  182.                                 
  183.         'infa', 1070;            // 68K compatable file
  184.         },
  185.     }
  186. };
  187.  
  188.  
  189.  
  190. // • package comments
  191.  
  192. // NOTE: The actual file that will be installed in either package is actually 
  193. // TeachText. The information detailed below does not actually correspond to 
  194. // the file being installed and is intended only as an example of how to prepare 
  195. // custom package information resources.
  196.  
  197. // FURTHER NOTE: The values that are assigned to the Custom Package Information 
  198. // resource fields do not actually have any effect on the installation and are 
  199. // ignored during installation. They can however assist the user in choosing which 
  200. // packages they would like to include in their Custom Installation or Custom Removal.
  201.  
  202. // The following included file contains the icons for the two package comments.
  203. // I created the file with the icon resources ( in this case 'icl4' and 'icl8' )
  204. // by opening the application to be installed within ResEdit. I then copied the
  205. // 'ICN#', 'icl4' and 'icl8' icon resources into a new ResEdit file called 
  206. // "Icons.rsrc" and assigned the resource items an ID of 9128, since their original 
  207. // resource ID's had a value that was illegal for use with 'inpc' resources 
  208. // ( they must be over 1024 ).
  209. // - An alternative to this method is to derez the application and to paste the 
  210. // resulting resource definitions into this script file and to let the Rez command 
  211. // build the icons every time that the installer script is Rezzed. If you happen 
  212. // to forget to include the resources for the icons, ScriptCheck will complain, 
  213. // but you will still be able to use the Rezzed installer script to successfully 
  214. // perform an installation. 
  215. include "Icons.rsrc";
  216.  
  217. resource 'inpc' ( kPowerMacPackage ) {
  218.     format1 {
  219.         8021994,                // sample date ( 08/02/94 )
  220.         403,                    // sample version ( 4.0.3 )
  221.         
  222.         2500 * 1024,            // RAM required for package ( 2.5 megabytes )
  223.         
  224.         9128,                    // icon rsrc ID ( 'ICN#', 'icl4', 'icl8' )
  225.                                 // - ID must be greater than 1024
  226.                                 // - resource item in rezzed script file
  227.                                 
  228.         kPowerMacPackage,        // 'TEXT' resource ID of item  
  229.                                 // containing package description
  230.         
  231.     }
  232. };
  233.  
  234. resource 'inpc' ( k68000Package ) {
  235.     format1 {
  236.         8021994,                // sample date ( 08/02/94 )
  237.         403,                    // sample version ( 4.0.3 )
  238.  
  239.         4250 * 1024,            // RAM required for package ( 4.25 megabytes )
  240.         
  241.         9128,                    // icon rsrc ID ( 'ICN#', 'icl4', 'icl8' )
  242.                                 // - ID must be greater than 1024
  243.                                 // - resource item in rezzed script file
  244.  
  245.         k68000Package,            // 'TEXT' resource ID of item  
  246.                                 // containing package description
  247.     }
  248. };
  249.  
  250.  
  251. // The following resource items can easily be created manually by creating 'TEXT' 
  252. //  resource items in a file and including that file in this script.
  253. // USE: include "fileWithTextItem.rsrc";    
  254. // NOTE : resource includes use "include" instead of "#include" 
  255. //         and are terminated with a semicolon.
  256. data 'TEXT' ( kPowerMacPackage ) {
  257.     "This is some sample text that would describe what the Power Macintosh "
  258.     "compatible package contains."
  259. };
  260.  
  261. data 'TEXT' ( k68000Package ) {
  262.     "This is some sample text that would describe what the 68000 CPU compatible "
  263.     "package contains."
  264. };
  265.  
  266.  
  267.  
  268. // • file atoms
  269.  
  270. // file atom for PowerMac version
  271. resource 'infa' (1075) {
  272.     format1 {
  273.         deleteWhenRemoving,
  274.         deleteWhenInstalling,
  275.         copy,                        
  276.         dontIgnoreLockedFile,
  277.         dontSetFileLocked,
  278.         useSrcCrDateToCompare,        
  279.         srcNeedExist,
  280.         rsrcForkInRsrcFork,
  281.         leaveAloneIfNewer,            
  282.         updateExisting,                
  283.         copyIfNewOrUpdate,
  284.         rsrcFork,
  285.         dataFork,
  286.         0,
  287.         0x0,
  288.         10075,
  289.         {    
  290.             10076, 
  291.             0, 
  292.             0    
  293.         },
  294.         0,                            
  295.         0,
  296.         0,
  297.         "TeachText • PowerMac"
  298.     }
  299. };
  300.  
  301. // file atom for 68K version
  302. resource 'infa' (1070) {
  303.     format1 {
  304.         deleteWhenRemoving,
  305.         deleteWhenInstalling,
  306.         copy,                        
  307.         dontIgnoreLockedFile,
  308.         dontSetFileLocked,
  309.         useSrcCrDateToCompare,        
  310.         srcNeedExist,
  311.         rsrcForkInRsrcFork,
  312.         leaveAloneIfNewer,            
  313.         updateExisting,                
  314.         copyIfNewOrUpdate,
  315.         rsrcFork,
  316.         dataFork,
  317.         0,
  318.         0x0,
  319.         10070,
  320.         {    
  321.             10071, 
  322.             0, 
  323.             0    
  324.         },
  325.         0,                            
  326.         0,
  327.         0,
  328.         "TeachText • 68K"
  329.     }
  330. };
  331.  
  332.  
  333. // • file specs
  334.  
  335. // target file spec for TeachText application
  336. resource 'intf' (10075) {
  337.     format1 {
  338.         noSearchForFile,                 // use default search path
  339.         
  340.         TypeCrMustMatch,                 // If this is set to TypeCrMustMatch
  341.                                         // then a file with a different type
  342.                                         // and creator than those specified
  343.                                         // below will not be replaced.
  344.                                         // If this is set to TypeCrNeedNotMatch
  345.                                         // then type and creator of an existing
  346.                                         // target file are ignored.
  347.         
  348.         // The Type and Creator fields will be used to set the
  349.         // file's Type and Creator when a new file is created. 
  350.         'APPL',                         // TYPE for new file
  351.         'ttxt',                         // CREATOR for new file
  352.         
  353.         0,                                 // finder attribute flags
  354.                                         // filled by ScriptCheck is value is 0
  355.         
  356.         1,                                  // creation date for new file
  357.         1,                                  // modification date for new file
  358.                                         // NOTE: DATE values are filled
  359.                                         // by ScriptCheck if the value is 1
  360.                                             
  361.         0,                                 // search proc ID ( 'insp' ), none used
  362.         
  363.         ":PowerMac Rules Example:TeachText • PowerMac" // path to target file
  364.         }
  365.     };
  366.  
  367.  
  368. // source file spec for TeachText application
  369. resource 'infs' (10076) {
  370.     'APPL',                        // TYPE for file search
  371.     'ttxt',                        // CREATOR for file search
  372.     
  373.     0x1,                        // creation DATE for source file
  374.                                 // ( value of 1, filled in by ScriptCheck
  375.                                 
  376.     noSearchForFile,            // IGNORED in Installer 4.0.x
  377.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  378.     "Disk 1:TeachText • PowerMac"    // PATH to source file        
  379. };
  380.  
  381.  
  382. // target file spec for TeachText application
  383. resource 'intf' (10070) {
  384.     format1 {
  385.         noSearchForFile,                 // use default search path
  386.         
  387.         TypeCrMustMatch,                 // If this is set to TypeCrMustMatch
  388.                                         // then a file with a different type
  389.                                         // and creator than those specified
  390.                                         // below will not be replaced.
  391.                                         // If this is set to TypeCrNeedNotMatch
  392.                                         // then type and creator of an existing
  393.                                         // target file are ignored.
  394.         
  395.         // The Type and Creator fields will be used to set the
  396.         // file's Type and Creator when a new file is created. 
  397.         'APPL',                         // TYPE for new file
  398.         'ttxt',                         // CREATOR for new file
  399.         
  400.         0,                                 // finder attribute flags
  401.                                         // filled by ScriptCheck is value is 0
  402.         
  403.         1,                                  // creation date for new file
  404.         1,                                  // modification date for new file
  405.                                         // NOTE: DATE values are filled
  406.                                         // by ScriptCheck if the value is 1
  407.                                             
  408.         0,                                 // search proc ID ( 'insp' ), none used
  409.         
  410.         ":PowerMac Rules Example:TeachText • 68K" // path to target file
  411.         }
  412.     };
  413.  
  414. // source file spec for TeachText application
  415. resource 'infs' (10071) {
  416.     'APPL',                        // TYPE for file search
  417.     'ttxt',                        // CREATOR for file search
  418.     
  419.     0x1,                        // creation DATE for source file
  420.                                 // ( value of 1, filled in by ScriptCheck
  421.                                 
  422.     noSearchForFile,            // IGNORED in Installer 4.0.x
  423.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  424.     "Disk 1:TeachText • 68K"        // PATH to source file        
  425. };
  426.  
  427.  
  428.